package com.db.ionio.serialization;

import com.thoughtworks.xstream.XStream;

import java.io.InputStream;
import java.io.OutputStream;

/**
 * @author Alexander Kotov (kotov.alex.22@gmail.com)
 */
public class XmlSerializer implements Serializer<SensorData[]> {
    @Override
    public String getType() {
        return "xml";
    }

    private final XStream xstream = new XStream();

    @Override
    public void serialize(SensorData[] obj, OutputStream outStream) throws Exception {
        xstream.toXML(obj, outStream);
    }

    @Override
    public SensorData[] deserialize(InputStream inStream) throws Exception {
        return (SensorData[])xstream.fromXML(inStream);
    }
}
